
package com.csc440.team2.activity;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

import com.csc440.team2.SmilConstants;
import com.csc440.team2.smil.SMILMessage;


/**
 * Main application menu, entry point for user interaction
 * 
 * @author Santiago Jamriska
 */
public class MainMenu extends ListActivity
{
    final static String[] MENUOPTIONS = new String[] {
            "NEW MESSAGE", "MESSAGES"
    };


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        setListAdapter(new ArrayAdapter<String>(this, R.layout.first_menu, MENUOPTIONS));

        ListView lv = getListView();
        lv.setTextFilterEnabled(true);
        lv.setOnItemClickListener(new OnItemClickListener()
        {
            public void onItemClick(AdapterView<?> parent, View clickedView, int position, long clickedItemId)
            {
                // have to set the new view
                if (position == SmilConstants.SELECTION_NEW_MESSAGE)
                {
                    Display display = getWindowManager().getDefaultDisplay();
                    SMILMessage message = SMILMessage.create(display.getWidth(), display.getHeight());

                    // changed the intent redirection
                    Intent in = new Intent(MainMenu.this, CreateSMILLayout.class);
                    in.putExtra(SmilConstants.MESSAGE, message);
                    MainMenu.this.startActivity(in);
                }
                else if (position == SmilConstants.SELECTION_INBOX)
                {
                    Intent in = new Intent(MainMenu.this, TabsMenu.class);
                    MainMenu.this.startActivity(in);
                }
            }
        });
    }
}